package ltd.hello.trik.snake;

import lombok.val;
import processing.core.PApplet;
import processing.core.PVector;

import static ltd.hello.trik.snake.SnakeCommon.SIZE;
import static processing.core.PApplet.floor;

/**
 * +----------------------------------------------------------------------
 * |
 * +----------------------------------------------------------------------
 * | <a href="https://www.hellotrik.ltd">Copyright (c) 2024~2025 </a>.
 * +----------------------------------------------------------------------
 * | Licensed MIT
 * +----------------------------------------------------------------------
 * | 作者: 🦠 matrixg 👾 <hellotrik@foxmail.com>
 * | 日期: 2024/9/6
 * +----------------------------------------------------------------------
 */
public class Food extends Cell {
    public Food(PApplet applet, PVector pos) {
        this.applet = applet;
        this.pos = pos;
        this.color.set(ToColor(PVector.random3D()));
    }

    public Food(PApplet applet) {
        this(applet,  new PVector((float) ((Math.random()-0.5)*(applet.height-5*SIZE)), (float) ((Math.random()-0.5)*(applet.height-5*SIZE)),(float) ((Math.random()-0.5)*(applet.height-5*SIZE))));
        this.color.set(ToColor(PVector.random3D()));
    }
//
//    @Override
//    public boolean collide(PVector cell) {
//        return pos.x==cell.x&&pos.y==cell.y;
//    }

    public Food clone() {
        val food = new Food(applet, pos);
        copy(food);
        return food;
    }
}
